<?php 
require_once 'common.inc.php';
require_once '../push/consor.class.php';
error_reporting(E_ALL);
include_once("../push/webconfig.php");
header("Content-type:text/html;charset=utf-8");
if($action=='close')
{
	$msg=4;
	$host="211.162.130.49";
	$test="192.168.0.251";
	$port=14796;
	$port1=14797;
	//sendin($msg,$test,$port);
	sendin($msg,$test,$port1);
	//sendin($msg,$host,$port);
	//sendin($msg,$host,$port1);
	///adminmsg('关闭！设置成功',"");
	
	//重写配置文件，并且删除缓存种子文件
		$filename="../push/webconfig.php";
		$fp=fopen($filename,'wb+');
		if($fp)
		{
			fwrite($fp,$msg);
			fclose($fp);
		}else
		echo "路径不对!";

		adminmsg('关闭！设置成功'.$msg,"");
}
elseif($action=='open')	//如果没有选择记录则执行添加关键字段操作
{
	
	$msg=3;
	$host="211.162.130.49";
	$test="192.168.0.251";
	$port=14796;
	$port1=14797;
	//sendin($msg,$test,$port);
	sendin($msg,$test,$port1);
	//sendin($msg,$host,$port);
	//sendin($msg,$host,$port1);
	//adminmsg('打开！设置成功',"");
	
	//重写配置文件，并且删除缓存种子文件
		$filename="../push/webconfig.php";
		$fp=fopen($filename,'wb+');
		if($fp)
		{
			fwrite($fp,$msg);
			fclose($fp);
		}else
		echo "路径不对!";
		
		//
		

		adminmsg('打开！设置成功'.$msg,"");
	
}
//echo "变量：".$msg;
	function sendin($msg,$host,$port)
	{
			$fp=fsockopen($host,$port,$errno,$errstr,30);
			if(!$fp)
			{
				 echo   'fuck';
			}
			else
			{
					fwrite($fp,$msg);
			//              echo 'fuck2';
					fclose($fp);
			}
	}

?>